﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>库存界面</title>
<link type="text/css" rel="stylesheet" href="/css/OutStock.css"/>
</head>
<body>
<!--顶部开始-->
    <div class="StockTop">
        <div class="StockHead">
            <span>商品出库</span>
        </div>
        <!--表格部分开始-->
        <div class="middel">
            <table class="table">
                <tr>
                    <th width="10%">编号</th>
                    <th width="15%">商品编号</th>
                    <th width="15%">商品名称</th>
                    <th width="10%">商品单价</th>
                    <th width="15%">商品描述</th>
                    <th width="15%">商品数量</th>
                    <th width="12%">出库数量</th>
                    <th width="15%">商品出库</th>
                </tr>

                <tr th:each="t,line : ${placeStock.items}">
                    <td><span th:text="${line.count}"></span></td>
                    <td><span th:text="${t.commodityId}"></span></td>
                    <td><span th:text="${t.name}"></span></td>
                    <td><span th:text="${t.price}"></span></td>
                    <td><span th:text="${t.describes}"></span></td>
                    <td><span th:text="${t.commodityCount}" id="commodityCount"></span></td>
                    <td><input type="number"name="commodityCount" class="inputCount"></td>
                    <td th:id="${t.commodityId}">
                        <a class="button-delete"><img src="/images/delete.png" width="20" height="20" alt="加载失败"></a>
                    </td>
                </tr>

            </table>
        </div>
        <!--表格部分结束-->
    </div>
<!--顶部结束-->
</body>
<script src="/js/jquery-2.2.1.min.js"></script>
<script src="/js/jump.js"></script>
<script type="text/javascript" th:inline="javascript">

    $(document).ready(function(){

        $(".inputCount").each(function(index,item){
            var maxNum=$(item).parent().prev().children().text();
            $(item).attr("max",maxNum);
            $(item).attr("min","1");
        })


    });

    //出库按钮按钮绑定事件
    $(".button-delete").bind("click",function () {
        alert("你好呀")
        var commodityId = $(this).parent().attr("id");
        var count = $(this).parent().prev().children().val();
        alert(commodityId);
        alert(count);
        // toJump("/lookCommodity/out","commodityId="+commodityId+"&commodityCount="+count);
        location="/lookCommodity/chakan?orderId="+orderId+"&commodityCount="+count;
    });

   // 绑定鼠标移出事件
    $(".inputCount").each(function (index,item) {
        $(item).mouseleave(function () {

            var commodityCount = $(this).parent().prev().children().text();
            var count = $(this).val();
            // alert(commodityCount);
            // alert(count);
            if(count > commodityCount){
                alert("数量不能超过库存数量！")
                $(this).val(1);
            }

        })
    })

</script>
</html>